import request from '@/config/axios'
import {
  InviteBusinessUrlListParams,
  memberCardListParams,
  memberCardItem,
  InviteBusinessDetailListParams,
  memberFeeConfigItem,
  businessListParams,
  businessEnterApply,
  businessEnterApplyAudit,
  memberFeeBillPageParams,
  merchantOpenParams
} from './types'

// 邀请商家链接列表
export const inviteBusinessUrlListApi = (params: InviteBusinessUrlListParams) => {
  return request.get({ url: '/inviteBusinessUrl/page', params })
}

// 邀请商家链接详情列表
export const inviteBusinessDetailListApi = (params: InviteBusinessDetailListParams) => {
  return request.get({ url: '/inviteBusinessUrl/pageEnterBusiness', params })
}

// 保存邀请商家链接
export const inviteBusinessUrlSaveApi = (data: any) => {
  return request.post({ url: '/inviteBusinessUrl/save', data })
}

// 删除邀请商家链接
export const inviteBusinessUrlDeleteApi = (id: number) => {
  return request.post({ url: `/inviteBusinessUrl/delete?id=${id}` })
}

// 下载邀请商家二维码
export const inviteBusinessUrlDownloadApi = (id: number) => {
  return request.post({
    url: '/inviteBusinessUrl/download',
    data: { id },
    responseType: 'blob'
  })
}

// 查看入驻商家
export const inviteBusinessUrlEnterBusinessApi = (params: any) => {
  return request.get({ url: '/inviteBusinessUrl/pageEnterBusiness', params })
}

// 商家配置列表
export const memberCardListApi = (params: memberCardListParams) => {
  return request.get({ url: '/memberCard/page', params })
}

// 保存火动次卡配置
export const memberCardSaveApi = (data: memberCardItem) => {
  return request.post({ url: '/memberCard/save', data })
}

// 更新火动次卡配置
export const memberCardUpdateApi = (data: memberCardItem) => {
  return request.post({ url: '/memberCard/update', data })
}

// 商家配置列表
export const memberFeeConfigListApi = (params: memberCardListParams) => {
  return request.get({ url: '/memberFeeConfig/page', params })
}

// 保存会员配置
export const memberFeeConfigSaveApi = (data: memberFeeConfigItem) => {
  return request.post({ url: '/memberFeeConfig/save', data })
}

// 更新会员配置
export const memberFeeConfigUpdateApi = (data: memberFeeConfigItem) => {
  return request.post({ url: '/memberFeeConfig/update', data })
}

// 商家列表
export const businessListApi = (params: businessListParams) => {
  return request.get({ url: '/business/page', params })
}

// 商户列表
export const merchantListApi = (params: businessListParams) => {
  return request.get({ url: '/merchant/page', params })
}

// 商家详情
export const businessDetailsApi = (id: number) => {
  return request.get({ url: '/business/details', params: { id } })
}

// 商家入驻列表
export const businessEnterApplyListApi = (params: businessEnterApply) => {
  return request.get({ url: '/businessEnterApply/page', params })
}

// 手动开通商户业务
export const merchantOpenApi = (data: merchantOpenParams) => {
  return request.post({ url: '/businessEnterApply/merchantOpen', data })
}

// 手动开通子账号
export const merchantSubAcctOpenApi = (id: number) => {
  return request.post({ url: '/businessEnterApply/merchantSubAcctOpen', data: { id } })
}

// 商家入驻详情
export const businessEnterApplyDetailsApi = (id: number) => {
  return request.get({ url: '/businessEnterApply/details', params: { id } })
}

// 商家入驻申请审核
export const businessEnterApplyAuditApi = (data: businessEnterApplyAudit) => {
  return request.post({ url: '/businessEnterApply/audit', data })
}

// 商家会员续费记录列表
export const memberFeeBillPageApi = (params: memberFeeBillPageParams) => {
  return request.get({ url: '/business/memberFeeBillPage', params })
}

// 赠送会员
export const giveMemberFeeApi = (data: any) => {
  return request.post({ url: '/business/giveMemberFee', data })
}

// 修改权益
export const changeRightsApi = (data: any) => {
  return request.post({ url: '/business/changeRights', data })
}
